package mk.com.ldm.corepoint.implementation.client.view;

import mk.com.ldm.corepoint.implementation.client.lib.Constants.CPConstants;
import mk.com.ldm.corepoint.implementation.client.presenter.EditPresenter;

import org.gwt.mosaic.ui.client.WindowPanel;

import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

public class EditView extends Composite implements EditPresenter.Display{

	private final WindowPanel winModal;
	private FlexTable form;
	private Button saveReport;
	private ListBox pageType = new ListBox();
		
	//TODO: Form generator, Customized views, Custom permissions (read from LoginData)
	public EditView(String type, String id){
		winModal = new WindowPanel();
		form = new FlexTable();
		winModal.setCaption(id);
		winModal.setModal(true);
		winModal.setGlassEnabled(true);
		//TODO: FORM GENERATOR, read map -> create widgets
		
	}


	public Widget asWidget() {
		return this;
	}	
	
	public void setForm(Widget form){
		winModal.setWidget(form);
		winModal.pack();
		winModal.center();
		winModal.show();
	}
	
	public void setForm(Widget form, String buttonText){
		pageType.addItem("Portrait", "0");
		pageType.addItem("Landscape", "1");
		VerticalPanel panel = new VerticalPanel();
		panel.add(form);
		HorizontalPanel hp = new HorizontalPanel();
		saveReport = new Button(CPConstants.SAVE_IMAGE+"<div>"+buttonText+"</div>");
		hp.add(pageType);
		hp.add(saveReport);
		panel.add(hp);
		panel.setHeight("300px");
		winModal.setWidget(panel);
		winModal.pack();
		winModal.setHeight("320px");
		winModal.center();
		winModal.show();
	}
	
	public WindowPanel getWindow(){
		return winModal;
	}
	
	public Button getReportButton(){
		return saveReport;
	}
	
	public ListBox getPageType(){
		return pageType;
	}
	
	
}
